<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>员工列表</title>
  <!--<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>-->
  <script src="/static/jqueryui/jquery-3.4.1.js"></script>
  <script src="/static/jqueryui/jquery.cookie.js"></script>
</head>
<script type="text/javascript">
  $(function () {
    let username = $.cookie('rem');
    if (typeof (username) != 'undefined') {
      const user = username.split(/[\s]/)[0];
      const pswd = username.split(/[\s]/)[1];
      $("#user").val(user)
      $("#pswd").val(pswd)
    }
    let cookieRemAccount = $.cookie('remAccount');
    console.log("cookieRemAccount:", cookieRemAccount, typeof cookieRemAccount);
    if (cookieRemAccount === 'true') {
      $("#rem").prop("checked", true)
    }
    else {
      $("#rem").prop("checked", false)
    }
  })
  function change() {
    const status = $("#rem").prop("checked");
    if (status) {
      $.cookie('remAccount', 'true', {expires: 7});
      $("#rem1").val("true");
    }
    else {
      $.cookie('remAccount', 'false', {expire: -1});
      $("#rem1").val("false");
    }
  }
</script>
<body>
<h1>欢迎：[[${session.loginUser}]]</h1>
<form action="/testRemPassword" method="post">
  账号: <input type="text" id="user" name="username" value="">${session.username}
  密码: <input type="password" id="pswd" name="password" value="">
  记住账号密码: <input type="checkbox" name="rem" id="rem" onclick="change()">
  登录: <input type="submit">
  <input type="hidden" name="rem" id="rem1" value="false">
</form>
</body>
</html>